package vooga.entities;

import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;

import vooga.geom.Vector;

public class Line extends Entity
{
    public Line (Point2D start, Point2D end)
    {
        super(helpFrame(start, end),
            new Line2D.Double(0, 0, 1, 1));
    }

    public Point2D getStart ()
    {
        return new Point2D.Double(getLeft(), getTop());
    }

    public Point2D getEnd ()
    {
        return new Point2D.Double(getRight(), getBottom());
    }
        
    /**
     * help get the framing rectangle for a line
     * @param start start of line
     * @param end end of line
     * @return framing rectangle for a line
     */
    protected static Rectangle2D helpFrame(Point2D start, Point2D end)
    {
    	Rectangle2D temp = new Rectangle2D.Double();
    	temp.setFrameFromDiagonal(start, end);
    	return temp;
    }
    
    /**
     * help build representation of line (for constructor)
     * @param start start of line
     * @param end end of line
     * @return new Line2D.Double(0,0,1,1) if line pointing towards 1st or 3rd
     * quadrants else new Line2D.Double(0,1,1,0)
     */
    protected static Line2D helpRepresentation(Point2D start, Point2D end)
    {
    	Vector temp = new Vector(start, end);
        return (temp.getDirection() < 90) ||
        		(temp.getDirection() > 180 && temp.getDirection() < 270) ?
        			new Line2D.Double(0,0,1,1) : new Line2D.Double(0,1,1,0);
    }
    
}


//BAD CODE IN THIS CLASS
